package com.baizhi.hospital.controller;

import com.baizhi.hospital.annotation.LogAnnotation;
import com.baizhi.hospital.entity.Drug;
import com.baizhi.hospital.service.DrugService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/drug")
public class drugController {

	@Resource
	private DrugService drugService;


	@RequestMapping("/selectDrug")
	@LogAnnotation(value = "查询所有的药品信息",type = 2)
	public Map<String,Object> selectDrug(int page,int limit,String drugName){
		return drugService.selectDrugPage(page, limit, drugName);
	}



	@RequestMapping("/insertDrug")
	@LogAnnotation(value = "添加药品信息",type = 2)
	public Map<String,Object> insertDrug(Drug drug){
		return drugService.insertDrug(drug);
	}



	@RequestMapping("/deleteByDrugId")
	@LogAnnotation(value = "删除药品信息",type = 2)
	public Map<String,Object> deleteByDrugId(String drugId){
		return drugService.deleteByDrugId(drugId);
	}

	@RequestMapping("/updateDrugSaleStatus")
	@LogAnnotation(value = "对药品进行上下架处理",type = 2)
	public Map<String ,Object> updateDrugSaleStatus(String drugId,int drugSaleStatus){
		return drugService.updateDrugSaleStatus(drugId,drugSaleStatus);
	}


	@RequestMapping("/updateDrug")
	@LogAnnotation(value = "修改药品信息",type = 2)
	public Map<String, Object> updateDrug(Drug drug){
		return drugService.updateDrug(drug);
	}

}
